package com.example.controller;

import com.alibaba.fastjson.JSONObject;
import com.example.annotations.*;
import com.example.auth.model.UserModel;
import com.example.auth.service.UserModelService;
import com.example.model.UploadBody;
import com.example.model.UploadModel;
import com.example.service.ExampleService;
import com.example.utils.Results;

import java.util.List;
import java.util.Map;

/**
 * @Classname DemoController
 * @Description TODO
 * @Date 2022/7/27 19:21
 * @Created by XiongXiong
 * @Author: X.I.O
 */
@RestController("/demo")
public class DemoTestController {

    @Autowired
    UserModelService userModelService;

    @Auth
    @GetMapping("/post")
    public JSONObject demoController(){
        UserModel userModel=userModelService.getUserModel();
        if(userModel==null){
            System.out.println("是空的");
        }
        System.out.println(JSONObject.toJSONString(userModel));
        return Results.success("你访问我了");
    }

    @PostMapping("/testpost")
    public JSONObject testController(){
        UserModel userModel=userModelService.getUserModel();
        System.out.println("----");
        if(userModel==null){
            System.out.println("是空的");
        }
        System.out.println(JSONObject.toJSONString(userModel));
        return Results.success("你访问我了");
    }

    @PostMapping("/demotestpost")
    public JSONObject printController(){
        UserModel userModel=userModelService.getUserModel();
        List<Map<String,Object>> mapList=exampleService.selectMapList();
        JSONObject object=Results.success();
        object.put("user",userModel);
        object.put("data",mapList);
        return object;
    }



    @Autowired
    private ExampleService exampleService;
}
